Skip to content

feat: complete range repartition physical planning#23617

Open
saadtajwar wants to merge 12 commits into
apache:mainfrom
saadtajwar:saadtajwar/finish-range-repartition-physical-plan
Open

feat: complete range repartition physical planning#23617
saadtajwar wants to merge 12 commits into
apache:mainfrom
saadtajwar:saadtajwar/finish-range-repartition-physical-plan

Conversation

@saadtajwar

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

After #23231 was merged in for supporting physical execution of the range repartitioning scheme, we still had a few methods on physical planning unimplemented, specifically try_swapping_with_projection, try_pushdown_sort, repartitioned - this PR finishes the implementation of those methods

What changes are included in this PR?

  • try_swapping_with_projection: similar to the Hash scheme, for Range we call update_expr for each of the range key expressions to attempt rewriting based on the projection expressions
  • try_pushdown_sort: same as other variants, we delegate to the child and wrap with a new RepartitionExec
  • repartitioned: unable to support for Range, left comment in codebase with explanation

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions Bot added the physical-plan Changes to the physical-plan crate label Jul 15, 2026
@saadtajwar
saadtajwar marked this pull request as ready for review July 15, 2026 16:15
@saadtajwar

Copy link
Copy Markdown
Contributor Author

cc @gene-bordegaray & @gabotechs ! Thanks in advance for any feedback! 😁 🎉

@gene-bordegaray gene-bordegaray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some feedback, thank you 🙇

Comment thread datafusion/physical-plan/src/repartition/mod.rs Outdated
Comment thread datafusion/physical-plan/src/repartition/mod.rs
Comment thread datafusion/physical-plan/src/repartition/mod.rs Outdated
Comment thread datafusion/physical-plan/src/repartition/mod.rs
@saadtajwar

Copy link
Copy Markdown
Contributor Author

@gene-bordegaray thanks for the feedback! Pushed a commit to address - appreciate all the time taken reviewing!

@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.00881% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.66%. Comparing base (1e58928) to head (b654808).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/physical-plan/src/repartition/mod.rs 74.00% 35 Missing and 24 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23617      +/-   ##
==========================================
- Coverage   80.67%   80.66%   -0.01%     
==========================================
  Files        1086     1086              
  Lines      366800   367022     +222     
  Branches   366800   367022     +222     
==========================================
+ Hits       295912   296073     +161     
- Misses      53260    53294      +34     
- Partials    17628    17655      +27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gene-bordegaray gene-bordegaray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this, I think my earlier comment may have pushed this a little too far in the helper direction 😅

What I was trying to get at was mostly reducing the repeated range-partitioning setup, not adding a bunch of extra test scaffolding / coverage. I think we can keep this much tighter:

  • one positive projection-swap test that verifies the range key is rewritten when its projected column index changes
  • one negative projection-swap test that covers dropping a single key and dropping part of a compound key
  • two sort-pushdown tests: supported when the range repartition maintains input order, unsupported when it does not
  • keep the repartitioned() None test

I’d drop the extra execution sortedness test since this PR really about the planning behavior.

For helpers I think the useful ones are only the small range-specific setup things like build range partitioning from cols, build a projection from cols, unwrap/assert range partitioning.

@saadtajwar

Copy link
Copy Markdown
Contributor Author

Thanks for updating this, I think my earlier comment may have pushed this a little too far in the helper direction 😅

What I was trying to get at was mostly reducing the repeated range-partitioning setup, not adding a bunch of extra test scaffolding / coverage. I think we can keep this much tighter:

  • one positive projection-swap test that verifies the range key is rewritten when its projected column index changes
  • one negative projection-swap test that covers dropping a single key and dropping part of a compound key
  • two sort-pushdown tests: supported when the range repartition maintains input order, unsupported when it does not
  • keep the repartitioned() None test

I’d drop the extra execution sortedness test since this PR really about the planning behavior.

For helpers I think the useful ones are only the small range-specific setup things like build range partitioning from cols, build a projection from cols, unwrap/assert range partitioning.

Haha no worries, my bad - updated! Thanks again for reviewing :)

@gene-bordegaray gene-bordegaray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking much better 🚀

Comment thread datafusion/physical-plan/src/repartition/mod.rs Outdated
Comment thread datafusion/physical-plan/src/repartition/mod.rs Outdated
Comment thread datafusion/physical-plan/src/repartition/mod.rs Outdated
Comment thread datafusion/physical-plan/src/repartition/mod.rs Outdated
Comment thread datafusion/physical-plan/src/repartition/mod.rs
@saadtajwar

Copy link
Copy Markdown
Contributor Author

looking much better 🚀

Addressed! 🙌

@gene-bordegaray gene-bordegaray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now 👍 thank you @saadtajwar

ready for you now @gabotechs 🙇

);
assert!(repartition.maintains_input_order()[0]);

match repartition.try_pushdown_sort(ordering.as_ref())? {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: maybe one last assert comparing the sort of the pushed repartiton and required 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete physical execution planning of range partitioning

3 participants